package com.tt.fashionWebSite.controller;

import com.tt.fashionWebSite.dto.*;
import com.tt.fashionWebSite.service.Ad_MemberMeasurementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.List;
import java.util.Map;

@Controller
public class Ad_MemberMeasurementController {
    @Autowired
    private Ad_MemberMeasurementService ad_memberMeasurementService;

    @SuppressWarnings("rawtypes")
    @RequestMapping(value = "/admin/header/adMemberMeasurement", method = RequestMethod.POST)
    public @ResponseBody
    JsonResponseDto<Integer> adminMemberMeasurement(HttpServletRequest request, @RequestBody SoDoCoTheDto memberMeasurementDto) {
        return new JsonResponseDto<Integer>(ad_memberMeasurementService.adminMemberMeasurement(memberMeasurementDto));
    }

    @SuppressWarnings("rawtypes")
    @RequestMapping(value = "/admin/getMemberMeasurement", method = RequestMethod.GET)
    public @ResponseBody
    JsonResponseDto<List<SoDoCoTheDto>> getMemberMeasurement(HttpServletRequest request) {
        return new JsonResponseDto<List<SoDoCoTheDto>>(ad_memberMeasurementService.getMemberMeasurement(), JsonResponseCode.SUCCESS);
    }

    @SuppressWarnings("rawtypes")
    @RequestMapping(value = "/admin/toMemberMeasurementPage/{maSDCoThe}", method = RequestMethod.GET)
    public @ResponseBody
    ModelAndView toPageMemberMeasurement(HttpServletRequest request, @PathVariable String maSDCoThe, Map<String, Object> map) throws ParseException {
        map.put("maSDCoThe", maSDCoThe);
        return new ModelAndView("admin/ad-member-measurement-edit");
    }

    @SuppressWarnings("rawtypes")
    @RequestMapping(value = "/admin/editMemberMeasurement", method = RequestMethod.POST)
    public @ResponseBody
    JsonResponseDto<SoDoCoTheDto> getMemberMeasurementInfoEdit(HttpServletRequest request, @RequestBody SoDoCoTheDto measurementDto) {
        return new JsonResponseDto<SoDoCoTheDto>(ad_memberMeasurementService.getMemberMeasurementInfoEdit(measurementDto), JsonResponseCode.SUCCESS);
    }

    @SuppressWarnings("rawtypes")
    @RequestMapping(value = "/admin/registerMemberMeasurementEdit", method = RequestMethod.POST)
    public @ResponseBody
    JsonResponseDto<SoDoCoTheDto> registerColorEdit(HttpServletRequest request, @RequestBody SoDoCoTheDto measurementDto) {
        return new JsonResponseDto<SoDoCoTheDto>(ad_memberMeasurementService.registerMemberMeasurementEdit(measurementDto), JsonResponseCode.SUCCESS);
    }

}